package com.yby6.web.controller.system;

import com.yby6.common.core.AjaxResult;
import com.yby6.common.core.controller.BaseController;
import com.yby6.common.core.page.TableDataInfo;
import com.yby6.common.utils.poi.ExcelUtil;
import com.yby6.face.domain.SysUserFaceInfo;
import com.yby6.face.service.SysUserFaceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户人脸识别Controller
 *
 * @author yangbuyi
 * @date 2022-04-25
 */
@RestController
@RequestMapping("/system/userFaceInfo")
public class SysUserFaceInfoController  extends BaseController {
    @Autowired
    private SysUserFaceInfoService sysUserFaceInfoService;

    /**
     * 查询用户人脸识别列表
     */
    @GetMapping("/list")
    public TableDataInfo list (SysUserFaceInfo sysUserFaceInfo) {
        startPage();
        List<SysUserFaceInfo> list = sysUserFaceInfoService.selectSysUserFaceInfoList(sysUserFaceInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户人脸识别列表
     */
    @GetMapping("/export")
    public AjaxResult export (SysUserFaceInfo sysUserFaceInfo) {
        List<SysUserFaceInfo> list = sysUserFaceInfoService.selectSysUserFaceInfoList(sysUserFaceInfo);
        ExcelUtil<SysUserFaceInfo> util = new ExcelUtil<SysUserFaceInfo>(SysUserFaceInfo.class);
        return util.exportExcel(list, "用户人脸识别数据");
    }

    /**
     * 获取用户人脸识别详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo (@PathVariable("id") Long id) {
        return AjaxResult.success(sysUserFaceInfoService.selectSysUserFaceInfoById(id));
    }

    /**
     * 新增用户人脸识别
     */
    @PostMapping
    public AjaxResult add (@RequestBody SysUserFaceInfo sysUserFaceInfo) {
        return toAjax(sysUserFaceInfoService.insertSysUserFaceInfo(sysUserFaceInfo));
    }

    /**
     * 修改用户人脸识别
     */
    @PutMapping
    public AjaxResult edit (@RequestBody SysUserFaceInfo sysUserFaceInfo) {
        return toAjax(sysUserFaceInfoService.updateSysUserFaceInfo(sysUserFaceInfo));
    }

    /**
     * 删除用户人脸识别
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove (@PathVariable Long[] ids) {
        return toAjax(sysUserFaceInfoService.deleteSysUserFaceInfoByIds(ids));
    }
}
